/*
ID:luongho3
LANG:JAVA
TASK:lamps
 */
package usaco.training.chap2.sec2;

import java.io.File;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class lamps {
	
	static int[] lam, fin;
	static int N, C, count;

	public static void main(String[] args) throws Exception {
		Scanner scanner = new Scanner(new File("lamps.in"));
		PrintStream ps = new PrintStream(new File("lamps.out"));
		System.setOut(ps);
		N = scanner.nextInt();
		C = scanner.nextInt();
		lam = new int[N];
		fin = new int[N];
		int idx;
		do {
			idx = scanner.nextInt();
			if (idx == -1) {
				break;
			}
			else {
				fin[idx-1] = 1;
			}
		} while(true);
		
		do {
			idx = scanner.nextInt();
			if (idx == -1) {
				break;
			}
			else {
				fin[idx-1] = -1;
			}
		} while(true);
		
		int[] b = new int[5];
		count = 0;
		String[] ss = new String[100];
		for (int i=0;i<16;++i) {
			init();
			int val = i;
			for (int j=1;j<=4;++j) {
				b[j] = val % 2;
				val /= 2;
			}
			if (valid(b)) {
				for (int j=1;j<=4;++j) {
					if (b[j] == 1) {
						change(j);
					}
				}
				if (match()) {
					String s = getString();
					ss[count] = s;
					count++;
				}
			}
		}
		
		if (count == 0) {
			System.out.println("IMPOSSIBLE");
		}
		else {
			Arrays.sort(ss,0,count);
			System.out.println(ss[0]);
			for (int i=1;i<count;++i) {
				if (ss[i].compareTo(ss[i-1]) != 0) {
					System.out.println(ss[i]);
				}
			}
		}

	}

	private static String getString() {
		StringBuilder b = new StringBuilder();
		for (int i=0;i<N;++i) {
			if (lam[i] == 1) {
				b.append(lam[i]);
			}
			else {
				b.append(0);
			}
		}
		return b.toString();
	}

	private static boolean match() {
		for (int i=0;i<N;++i) {
			if (fin[i] != 0) {
				if (fin[i] != lam[i]) {
					return false;
				}
			}
		}
		return true;
	}

	private static void change(int j) {
		if (j == 1) {
			for (int i=0;i<N;++i) {
				lam[i] = -lam[i];
			}
		}
		else if (j == 2) {
			for (int i=0;i<N;++i) {
				if ((i+1) % 2 == 1) {
					lam[i] = -lam[i];
				}
			}
		}
		else if (j == 3) {
			for (int i=0;i<N;++i) {
				if ((i+1) % 2 == 0) {
					lam[i] = -lam[i];
				}
			}
		}
		else if (j == 4) {
			for (int i=0;i<N;++i) {
				if ((i+1) % 3 == 1) {
					lam[i] = -lam[i];
				}
			}
		}
		
	}

	private static boolean valid(int[] b) {
		int sum = b[1] + b[2] + b[3] + b[4];
		if (sum > C) {
			return false;
		}
		else {
			int tmp = C- sum;
			if (tmp % 2 == 0) {
				return true;
			}
			else {
				return false;		
			}
		}
	}

	private static void init() {
		for (int i=0;i<N;++i) {
			lam[i] = 1;
		}
	}

}
